﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using RunAllTestsInSolutionTask;
using System.Xml;

namespace RunAllTestsInSolutionTaskTests
{

    [TestFixture]
    class CSharpProjectParserTests : BaseProjectParserTests
    {
        private const string CSHARP_RUN_ALL_TESTS_PROJECT = @"TestData\RunAllTestsInSolution.csproj";
        private const string CSHARP_EXE_PROJECT = @"TestData\SimpleExeProject.csproj";
        private const string RUN_ALL_TESTS_DEBUG_DLL_FILE = @"TestData\bin\Debug\RunAllTestsInSolution.dll";
        private const string RUN_ALL_TESTS_RELEASE_DLL_FILE = @"TestData\bin\Release\RunAllTestsInSolution.dll";
        private const string EXE_DEBUG_EXE_FILE = @"TestData\bin\Debug\SimpleExeProject.exe";

        protected const string MSTEST_PROJECT_FILE = @"TestData\CTesting.AddinTests.csproj";
        protected const string CSHARP_PRODUCTION_PROJECT = @"TestData\RunAllTestsInSolution.csproj";

        [Test]
        public void IsTestProject_GivenMsTestProject_ReturnsTrue()
        {
            var target = new CSharpProjectParser(MSTEST_PROJECT_FILE);
            var actual = target.IsTestProject();
            Assert.IsTrue(actual);
        }

        [Test]
        public void IsTestProject_NotTestProject_ReturnsFalse()
        {
            var target = new CSharpProjectParser(CSHARP_PRODUCTION_PROJECT);
            var actual = target.IsTestProject();
            Assert.IsFalse(actual);
        }

        [Test]
        public void GetOutputDll_ForDebug_ReturnsDebugDllName()
        {
            var target = new CSharpProjectParser(CSHARP_RUN_ALL_TESTS_PROJECT);

            var dllName = target.GetOutputFile("Debug");

            Assert.AreEqual(RUN_ALL_TESTS_DEBUG_DLL_FILE, dllName);
        }

        [Test]
        public void GetOutputDll_ForRelease_ReturnsReleaseDllName()
        {
            var target = new CSharpProjectParser(CSHARP_RUN_ALL_TESTS_PROJECT);

            var dllName = target.GetOutputFile("Release");

            Assert.AreEqual(RUN_ALL_TESTS_RELEASE_DLL_FILE, dllName);
        }

        [Test]
        public void GetOutputDll_ForExeProject_FileNameExtensionIsExe()
        {
            var target = new CSharpProjectParser(CSHARP_EXE_PROJECT);

            var dllName = target.GetOutputFile("Debug");

            Assert.AreEqual(EXE_DEBUG_EXE_FILE, dllName);
            
        }

    }
}
